import {reqHomeArtDetailAll} from "../../api/homeArtDetail"
Page({
  data: {
    "articleId": '',
    "channelId": 409,
    "nodes": '',
    "time": "",
    "name ": "",
    "titleName": ""
  },
  onLoad(p) {
		this.setData({
			articleId:p.id
		})
    this.getData()
  },
  async getData() {
    let {
      articleId,
      channelId
    } = this.data;
    let res = await reqHomeArtDetailAll({
      articleId,
      channelId
    })
    let nodes = res.data.detail;
    nodes = nodes.replace(/data\-src/g, "src")
    nodes = nodes.replace(/<img style="/gi, '<img style="max-width:100%;')

    this.setData({
      nodes: nodes,
      name : res.data.sourceName,
      titleName : res.data.name,
      time : res.data.updateTime
    })
    this.replaceDataSrc()
  },

  replaceDataSrc() {
    let arr = this.data.nodes.replace(/data\-src/g, "src");
    this.setData({
      nodes: arr
    })
  },
  goBack(){
    wx.navigateBack()
  },
})